<%@page import="java.util.Date"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>工作流提交</title>
<meta name="decorator" content="default" />
<%@include file="/WEB-INF/views/include/treeview.jsp" %>
	<style type="text/css">
		.ztree {margin:0;_margin-top:10px;padding:10px 0 0 10px;}
	</style>
<link href="${ctxStatic}/common/style.css" type="text/css" rel="stylesheet" />	
<script type="text/javascript">
	var ctx = 'http://localhost:8080';
	function page(n, s) {
		$("#pageNo").val(n);
		$("#pageSize").val(s);
		$("#searchForm").submit();
		return false;
	}
	
	$(document).ready(
			function() {
			$("#inputForm")
			.validate(
				{
					submitHandler : function(form) {
						resetTip();
						top.$.jBox.tip('正在提交，请稍等...','loading',{opacity:0,persistent:true});
						form.submit();
					},
					errorContainer : "#messageBox",
					errorPlacement : function(error, element) {
						$("#messageBox").text("输入有误，请先更正。");
						if (element.is(":checkbox")
								|| element.is(":radio")
								|| element.parent().is(
										".input-append")) {
							error.appendTo(element.parent()
									.parent());
						} else {
							error.insertAfter(element);
						}
					}
				});
			});
</script>
</head>
<body>


<form:form id="inputForm" modelAttribute="act" action="${ctx}/act/task/completeByTaskCommonForm" method="post" class="form-horizontal btnbottom" style="height: 457px;">	
<!-- 隐藏值 -->
<form:hidden path="processInstanceId" />
<form:hidden path="taskId" />
<form:hidden path="taskName" />
<form:hidden path="nextPathName"/>
<form:hidden path="nextPathId" />
<form:hidden path="flag" />
<form:hidden path="recordTable" />
<form:hidden path="businessIdColumn" />
<form:hidden path="businessIdValue" />
<form:hidden path="treeJsoData"/>

<form:hidden path="varKey1"/>
<form:hidden path="varValue1"/>
<form:hidden path="varKey2"/>
<form:hidden path="varValue2"/>
<form:hidden path="varKey3"/>
<form:hidden path="varValue3"/>



	   <div class="mainlist" style="height: 391px; overflow: auto;">
	   		<sys:message content="${message}"/>	
	      <div class="submitbox">
	      	<div class="box-info">
	       		<div class="box-leader">
	       			<div class="box-title"><span>处理意见</span></div>
	       			<form:textarea path="comment"  class="required" placeholder="请填写处理意见"/>
	       		</div>
	       		<div class="box-path">
	       			<div class="box-title"><span>选择路径</span></div>
	       			<div class="selectpath">
	       				<div class="box-p1 box-select">${act.nextPathName}</div>
	       				<!-- <div class="box-p1">返回到资产管理员 </div> -->
	       			</div>
	       			<script>
	       				$(".box-p1").click(function(){
	       					$(this).addClass("box-select");
	       					$(this).siblings().removeClass("box-select");
	       				});
	       			</script>
	       		</div>
	       	</div>
	       	<c:if test="${act.nextPathId !='endevent1'}">
	       	<div class="box-yj">
	       		<div class="box-title"><span>请选择办理人员(&nbsp;双击选中&nbsp;)</span></div>
	       		<div class="treeselect">
	       			<div id="ztree" class="ztree" style="height:auto !important;"></div>
	       		</div>
	       	</div>
	       	<div class="box-btn">
	       		<div class="box-title"><span>已选择处理人</span></div>
	       		<div class="hasselect selectlabel">
	       		    <c:if test="${act.assigneeName != null}">
	       			<span>${act.assigneeName}<i>×</i>
	       			<input name="assignee" type="hidden" value="${act.assignee}" />
	       			<input name="assigneeName" type="hidden" value="${act.assigneeName}" />
	       			</span>
	       			</c:if>
	       		</div>
	        </div>
	        </c:if>
	      </div>
	   </div>
	   
	   <jsp:include page="/WEB-INF/views/layouts/panelFormBtns.jsp">
	       <jsp:param name="btnSubmitName" value="提交" />
	   </jsp:include>
            
       
</form:form>
	   <script>
		   var setting = {data:{simpleData:{enable:true,idKey:"id",pIdKey:"pId",rootPId:'0'}},
					callback:{onClick:function(event, treeId, treeNode){
							var id = treeNode.id == '0' ? '' :treeNode.id;
							//$('#officeContent').attr("src","${ctx}/sys/user/list?office.id="+id+"&office.name="+treeNode.name);
							
							
						},
						onDblClick:function(event, treeId, treeNode){
							var nodeName=treeNode.name;
							var id=treeNode.id;
							
							if (treeNode.isParent){
								top.$.jBox.tip("不能选择父节点【"+nodeName+"】请重新选择。");
								return false;
							}
							
							var spans=$(".hasselect").find("span");
							var isadd=true;
							spans.each(function(count,event){
								var id_=$(event).find("input[name=assignee]").val();
								if(id_==id){
									top.$.jBox.tip("已选择该处理人【"+nodeName+"】");
									isadd=false;
								}
							});
							
							if(isadd){
								$(".hasselect").append("<span>"+nodeName+
										"<i>×</i>"+
										"<input type='hidden' name='assignee' value='"+id+"'/>"+
										"<input type='hidden' name='assigneeName' value='"+nodeName+"'/>"+
										"</span>"
									);
								isadd=true;
							}
							
							//绑定点击删除控件；
							removeselect();
						}
					}
				};
	   
		   function refreshTree(){
				/* $.getJSON("${ctx}/sys/office/treeData",function(data){
					$.fn.zTree.init($("#ztree"), setting, data).expandAll(true);
				}); */
				
			   var data=${act.treeJsoData};
				
			   $.fn.zTree.init($("#ztree"), setting, data).expandAll(true);
				
			}
		  
		   refreshTree();
		 //绑定点击删除控件；
		  removeselect();
		  function removeselect(){
			  $(".selectlabel i").click(function(){
				   $(this).parent().remove();
			   });
		  }
		   
	   </script>
	
</body>
</html>